{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import csv\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "num_epochs = 40"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "fig = plt.figure()\n",
    "for phase in ['train', 'valid']:\n",
    "\n",
    "    list_epoch    = []\n",
    "    list_loss     = []\n",
    "\n",
    "    for epoch in range(num_epochs):\n",
    "        with open('./log/{}_log_epoch{}.txt'.format(phase, epoch), 'r') as f:\n",
    "            reader = csv.reader(f, delimiter = '\\t')\n",
    "            d = list(reader)\n",
    "            list_epoch.append(float(d[0][0]))\n",
    "            list_loss.append(float(d[0][2]))\n",
    "        \n",
    "    if phase == 'train':\n",
    "        plt.plot(list_epoch, list_loss, color = 'red')\n",
    "    else:\n",
    "        plt.plot(list_epoch, list_loss, color = 'blue')\n",
    "\n",
    "    plt.xlabel('Epoch', fontsize = 15)\n",
    "    plt.ylabel('Loss', fontsize = 15)\n",
    "    plt.ylim(0, 0.01)\n",
    "    \n",
    "plt.savefig('./log/loss.jpg', dpi = fig.dpi)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "for phase in ['train', 'valid']:\n",
    "\n",
    "    list_epoch    = []\n",
    "    list_accuracy = []\n",
    "\n",
    "    for epoch in range(num_epochs):\n",
    "        with open('./log/{}_log_epoch{}.txt'.format(phase, epoch), 'r') as f:\n",
    "            reader = csv.reader(f, delimiter = '\\t')\n",
    "            d = list(reader)\n",
    "            list_epoch.append(float(d[0][0]))\n",
    "            list_accuracy.append(float(d[0][1]))\n",
    "        \n",
    "    if phase == 'train':\n",
    "        plt.plot(list_epoch, list_accuracy, color = 'red', label = 'Train: VGGFace2')\n",
    "    else:\n",
    "        plt.plot(list_epoch, list_accuracy, color = 'blue', label = 'Valid: LFW')\n",
    "\n",
    "    plt.xlabel('Epoch', fontsize = 15)\n",
    "    plt.ylabel('Accuracy', fontsize = 14)\n",
    "    plt.ylim(0.55, 1)\n",
    "    \n",
    "plt.legend(loc='upper left')\n",
    "plt.savefig('./log/accuracy.jpg', dpi = fig.dpi)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
